﻿using Microsoft.EntityFrameworkCore.Migrations;

namespace JuCheap.Core.Data.Migrations
{
    public partial class change_attendance_worker_id : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AlterColumn<int>(
                name: "WorkerId",
                table: "CheckWorkAttendances",
                nullable: true,
                oldClrType: typeof(int));

            migrationBuilder.AlterColumn<double>(
                name: "TotalHour",
                table: "CheckWorkAttendances",
                nullable: false,
                oldClrType: typeof(float));

            migrationBuilder.AlterColumn<double>(
                name: "AddedHour",
                table: "CheckWorkAttendances",
                nullable: false,
                oldClrType: typeof(float));

            migrationBuilder.CreateIndex(
                name: "IX_CheckWorkAttendances_WorkerId",
                table: "CheckWorkAttendances",
                column: "WorkerId");

            migrationBuilder.AddForeignKey(
                name: "FK_CheckWorkAttendances_Workers_WorkerId",
                table: "CheckWorkAttendances",
                column: "WorkerId",
                principalTable: "Workers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_CheckWorkAttendances_Workers_WorkerId",
                table: "CheckWorkAttendances");

            migrationBuilder.DropIndex(
                name: "IX_CheckWorkAttendances_WorkerId",
                table: "CheckWorkAttendances");

            migrationBuilder.AlterColumn<int>(
                name: "WorkerId",
                table: "CheckWorkAttendances",
                nullable: false,
                oldClrType: typeof(int),
                oldNullable: true);

            migrationBuilder.AlterColumn<float>(
                name: "TotalHour",
                table: "CheckWorkAttendances",
                nullable: false,
                oldClrType: typeof(double));

            migrationBuilder.AlterColumn<float>(
                name: "AddedHour",
                table: "CheckWorkAttendances",
                nullable: false,
                oldClrType: typeof(double));
        }
    }
}
